Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated semantics for atproto labelers header #2292

Merged
merged 5 commits into from
Mar 12, 2024
Merged

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Mar 11, 2024

Updated semantics for atproto labelers headers

# on requests
atproto-accept-labelers: did:web:mod.bsky.app;redact, did:plc:abc123, did:plc:xyz789

# on responses
atproto-content-labelers: did:web:mod.bsky.app;redact, did:plc:abc123, did:plc:xyz789


const makeResHeaders = (res: Response): Record<string, string> => {
const headers = RES_HEADERS_TO_FORWARD.reduce((acc, cur) => {
acc[cur] = res.headers.get(cur) ?? undefined
Copy link
Collaborator

@devinivy devinivy Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for headers.get(cur) to be null? That is the only case I can imagine the ?? undefined having an effect. If we want/need to deal with empty strings we could make this || undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah the return type for headers.get() is string | null 👍

Comment on lines 11 to 13
if (labeler.length === 0) {
continue
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would technically make the header invalid. If we want to pull in a parser, parseList() from structured-headers does what we need here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah nice, that sounds like it's probably worth it 👍

My thinking here was specificlaly for the case of an empty string val ie atproto-accept-labelers:

Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! We could handle malformed headers by erroring or treating it as though it's empty and assuming the default.

@devinivy
Copy link
Collaborator

devinivy commented Mar 11, 2024

It may be a bit much for now, but it's allowed to combined header values for lists if the header appears multiple times (see here). For example:

atproto-accept-labelers: did:plc:dan, did:plc:bryan
atproto-accept-labelers: did:plc:foysal

# may be equivalent to

atproto-accept-labelers: did:plc:dan, did:plc:bryan, did:plc:foysal

I could see us just punting on it for now but figured it's worth a note!

@dholms dholms merged commit 7b14660 into main Mar 12, 2024
10 checks passed
@dholms dholms deleted the atproto-accept-labelers branch March 12, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants